{__NOLAYOUT__}


<include file="Public/meta"/>
        
 <style type="text/css">
  .inv th{
    min-width: 60px;
    text-align: center;
  }
  .inv td{
    min-width: 60px;
    text-align: center;
  }
</style>       

<div class="container-fluid">
    <div class="row-fluid">
                    
    <div class="btn-toolbar">
        
        <!-- <a href="#myModal" data-toggle="modal" class="btn">删除</a> -->
      <div class="btn-group">
      </div>
    </div>
  <div class="well">
    
    <div id="myTabContent" class="tab-content">
      <div class="tab-pane active in" id="home">
    <form id="tab" method="post" >
      <table class="inv">
      <tr>
        <thead>
          <th>权限角色</th>
        </thead>
      </tr>
    <volist name="mage_role" id="rol">
      <tr>
        <tbody>
          <td>
           {$rol.role_name}
          </td>
          
          
          <td><a href="javascript:;" onclick="role_del('{$rol.mage_role_id}')" style="position: relative;top: -4px" data-toggle="modal" class="btn">删除</a></td>
         
        </tbody>
        
      </tr>
  </volist>

      <tr>
        <tbody>
          
          <td>
            <select name="role" id="role" style="width:150px;">
              <volist name='roles' id='ro'>
                <option value="{$ro.role_id}">{$ro.role_name}</option>
              </volist>
            </select>
          </td>
          
          
          
          
          <td><div class="btn btn-primary" id="add" onclick='role_add("{:U(\'Admin/Manager/edit_role\',array(\'mage_id\'=>$mage_id))}")' style="position: relative;top: -4px"><i></i>添加</div></td>
           
        </tbody>
      </tr>
    </table>

    </form>

      </div>
      
  </div>

</div>




<script type="text/javascript">

  



function role_add(url){
  
  
  var role = $("#role").val();
  

  
  $.ajax({
    type:'post',
    url:url,
    data:{role_id:role,status:1},
    dataType:'json',
    success:function(msg){
      if(msg.code==0){
        layer.msg(msg.info,{icon:2,time:1000});return false;
      }else{
        layer.msg(msg.info,{icon:1,time:1000},function(index){
          window.parent.location.reload();
        });
      }
      
    }
  })
}

// $('.edit').click(function(){
//   var color = $(this).html();
//   alert(color);return false;
// })


function inv_edit(obj,url){
  var color = $(obj).parent().siblings().children().eq(0).val();
  var size = $(obj).parent().siblings().children().eq(1).val();
  var price = $(obj).parent().siblings().children().eq(2).val();
  var inventory = $(obj).parent().siblings().children().eq(3).val();
  var pr_co_id = $(obj).parent().siblings().eq(5).val();
  var pro_id = $(obj).parent().siblings().eq(6).val();
  
  

  if(price==''){
    layer.msg('价格未填写',{icon:2,time:1000});
    return false;
  }else if(inventory == ''){
    layer.msg('库存未填写',{icon:2,time:1000});
    return false;
  }else if(inventory <= 0){
    layer.msg('库存最少为1',{icon:2,time:1000});
    return false;
  }

  
  $.ajax({
    type:'post',
    url:url,
    data:{color_id:color ,size_id:size,price:price,inventory:inventory,pr_co_id:pr_co_id,status:2,pro_id:pro_id},
    dataType:'json',
    success:function(msg){
      if(msg.code==0){
        layer.msg(msg.info,{icon:2,time:1000});return false;
      }else{
        layer.msg(msg.info,{icon:1,time:1000},function(index){
          
        });
      }
      
    }
  })
}


function role_del(mage_role_id){
  
  
  layer.confirm('确定删除吗',function(index){
    $.ajax({
      type:'post',
      url:'',
      data:{mage_role_id:mage_role_id,status:2},
      dataType:'json',
      success:function(msg){
        if(msg.code==0){
          layer.msg(msg.info,{icon:2,time:1000});return false;
        }else{
          layer.msg(msg.info,{icon:1,time:1000},function(index){
            window.parent.location.reload();
          });
        }
        
      }
    })
  });
  
}
  
  
</script>